import { apiService } from './api'

export interface DashboardStats {
  totalDevices: number
  onlineDevices: number
  totalEnergy: number
  energyTrend: number
  securityAlerts: number
  parkingOccupancy: number
  personnelCount: number
  maintenanceAlerts: number
}

export interface EnergyData {
  time: string
  consumption: number
  cost: number
}

export interface DeviceStatus {
  id: string
  name: string
  type: string
  status: 'online' | 'offline' | 'maintenance'
  location: string
  lastUpdate: string
}

export const dashboardService = {
  // 获取仪表板统计数据
  async getStats(): Promise<DashboardStats> {
    return apiService.get<DashboardStats>('/api/dashboard/stats')
  },

  // 获取能耗数据
  async getEnergyData(period: '24h' | '7d' | '30d'): Promise<EnergyData[]> {
    return apiService.get<EnergyData[]>(`/api/dashboard/energy?period=${period}`)
  },

  // 获取设备状态
  async getDeviceStatus(): Promise<DeviceStatus[]> {
    return apiService.get<DeviceStatus[]>('/api/dashboard/devices')
  },

  // 获取实时数据
  async getRealTimeData(): Promise<any> {
    return apiService.get<any>('/api/dashboard/realtime')
  },
}